package com.findyou.advice;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @Title: TxAdvice
 * @Author 贾金博
 * @Package com.findyou.advice
 * @Date 2024/2/7 15:50
 * @description: 使用普通方式进行事物的添加
 */
@Component
@Aspect
@Order(10)
public class TxAdvice {

    @Before("com.findyou.pointcut.MyPointCut.pc()")
    public void begin() {
        System.out.println("开启事物");
    }

    @AfterReturning("com.findyou.pointcut.MyPointCut.pc()")
    public void commit(){
        System.out.println("事物的提交");
    }

    @AfterThrowing("com.findyou.pointcut.MyPointCut.pc()")
    public void rollback() {
        System.out.println("事物回滚");
    }
}
